package com.tomehay.termprojectmanage_server.mapper;

import com.tomehay.termprojectmanage_server.pojo.Model.Termproject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tomehay.termprojectmanage_server.pojo.VO.TermProjectVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */
public interface TermprojectMapper extends BaseMapper<Termproject> {
    @Select("SELECT termproject.*,allocation.id as allocation_id,allocation.group_id from termproject,allocation,student_group,group_member WHERE termproject.course_id = #{course_id} " +
            "and allocation.term_project_id = termproject.id AND allocation.group_id = student_group.id AND group_member.group_id = student_group.id " +
            "and group_member.student_id = #{student_id}")
    List<TermProjectVO> GetTermProjects(int course_id, int student_id);

    @Select("SELECT termproject.* from termproject,allocation WHERE allocation.id = #{allocation_id} AND allocation.term_project_id = termproject.id")
    Termproject getTermProjectByAllocation(int allocation_id);
}
